from django.shortcuts import render
from django.views.generic import ListView, DetailView
from app3.models import Publisher


class PublisherList(ListView):
    # model = Publisher
    # queryset = Publisher.objects.all()[:5]
    context_object_name = 'publishers'
    template_name = 'app3/publisher.html'

    def get_queryset(self):
        # number = int(self.args[0])
        number = int(self.kwargs['number'])
        return Publisher.objects.all()[:number]

    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        context['additional'] = 'some data'
        return context


class PublisherDetail(DetailView):
    model = Publisher
    template_name = 'app3/pdetail.html'
    context_object_name = 'p'
